﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DHLPricing.OrderInfo
{
    public partial class BatchInfoInput : Form
    {
        public string OrderNumbers = string.Empty;

        public BatchInfoInput()
        {
            InitializeComponent();
        }

        private void BatchInfoInput_Shown(object sender, EventArgs e)
        {
            richTextBoxOrderNumbers.Text = OrderNumbers;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string batchInfo = txtBatchInfo.Text;
            string flightInfo = txtFlightInof.Text;
            DateTime flightTime = Convert.ToDateTime(dateTimePickerFlightTime.Text);
            string result = string.Empty;
            OrderServices.ArrayOfString OrderNumbersArray = new OrderServices.ArrayOfString();

            if (string.IsNullOrEmpty(batchInfo))
            {
                MessageBox.Show("请填入批次信息。");
                return;
            }

            if (string.IsNullOrEmpty(flightInfo))
            {
                MessageBox.Show("请填入航班信息。");
                return;
            }

            OrderNumbersArray.AddRange(OrderNumbers.Split(','));
            OrderServices.OrderServiceSoapClient client = new OrderServices.OrderServiceSoapClient();

            result = client.EditOrderBatchInfo(OrderNumbersArray, batchInfo, flightInfo, flightTime);

            if (result == "0")
            {
                MessageBox.Show("操作成功。");
                ((OrdersManage)this.Owner).BindOrderData();
                this.Close();
            }
            else
            {
                MessageBox.Show("操作失败:" + result);
            }
        }
    }
}
